import { http } from '../service';

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

// 运维端和sop管理端的模板列表
export function formlist(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/listByPage',
    method: 'GET',
    params,
  });
}

// 新增表单模板
export function formAdd(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/save',
    method: 'POST',
    data: params,
  });
}

// 编辑表单模板
export function formUpdate(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/update',
    method: 'POST',
    data: params,
  });
}

// 表单详情
export function formDetail(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/detail',
    method: 'GET',
    params,
  });
}

// 表单复制
export function formCopy(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/copy/save',
    method: 'POST',
    data: params,
  });
}

// 表单选择
export function formSelect(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/select/save',
    method: 'POST',
    data: params,
  });
}

// 表单启用/停用
export function updateStatus(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/updateStatus',
    method: 'POST',
    data: params,
  });
}

// 表单删除
export function formDelete(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/delete',
    method: 'POST',
    data: params,
  });
}
// 新增空白模板
export function formBlankAdd(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/empty/save',
    method: 'POST',
    data: params,
  });
}
// 业务关联表单列表
export function formBusinessList(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/template/list',
    method: 'GET',
    params,
  });
}

// 表单新增（应用端）
export function formAddApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/save',
    method: 'POST',
    data: params,
  });
}

// 表单删除（应用端）
export function formDeleteApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/delete',
    method: 'POST',
    data: params,
  });
}
// 表单选择（应用端）
export function formSelectApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/select/save',
    method: 'POST',
    data: params,
  });
}
// 表单列表 （应用端）
export function formListApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/list',
    method: 'GET',
    params,
  });
}
// 表单详情（应用端）
export function formDetailApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/detail',
    method: 'GET',
    params,
  });
}

// 编辑表单（应用端）
export function formUpdateApp(params: any) {
  return http.middleware<BasicResponseModel>({
    url: '/ctms/Rest/form/apply/update',
    method: 'POST',
    data: params,
  });
}

/**
 * 查询专业
 * @param params 查询条件
 * @returns 分页列表
 */
export function queryProfessionByOrg(params: any) {
  return http.middleware({
    url: '/system/Rest/sysMajor/listByPage/options',
    method: 'GET',
    params,
  });
}

/**
 * 根据专业查询PI
 * @param params 查询条件
 * @returns 分页列表
 */
export function queryPiByProfession(params: any) {
  return http.middleware({
    url: '/system/Rest/user/major/listByPage/options',
    method: 'GET',
    params,
  });
}

/**
 * 查询组织列表（根据组织类型）
 * @param params 查询条件
 * @returns 分页列表
 */
export function queryOrgByOrgType(params: any) {
  return http.middleware({
    url: '/system/Rest/org/listByPage/options',
    method: 'GET',
    params,
  });
}

// 【意向/立项】审批人显示此PI的在研项目数量
export function queryPiInResearchNum(params: any) {
  return http.middleware({
    url: '/ctms/Rest/project/apply/queryPiInResearchNum',
    method: 'GET',
    params,
  });
}

// 【意向/立项】审批人显示当前专业在研项目数量
export function queryMajorInResearchNum(params: any) {
  return http.middleware({
    url: '/ctms/Rest/project/apply/queryMajorInResearchNum',
    method: 'GET',
    params,
  });
}

// 任务表单提交
export function taskFormSubmit(data: any) {
  return http.middleware({
    url: `/ctms/Rest/project/task/form/submit`,
    method: 'POST',
    data,
  });
}
